<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/25
 * Time: 3:02
 */

$server = new swoole_websocket_server('0.0.0.0', 8813);

$server->on('open', 'onOpen');

function onOpen($server, $request) {
    print_r($request->fd);
};

$server->on('message', 'onMessage');

function onMessage($server, $frame){
    $server->push($frame->fd, 'push-success');
};

$server->on('close', function ($server, $fd) {
    echo "client {$fd} closed\n";
});

$server->start();